package com.framework.boc.statistics.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.framework.boc.response.CommonResponse;
import com.framework.boc.statistics.entity.TemplateField;
import com.framework.boc.statistics.service.impl.TemplateFieldServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.framework.boc.controller.BaseController;

import java.util.List;

/**
 * <p>
 * 统计模板字段表 前端控制器
 * </p>
 *
 * @author Leil
 * @since 2020-12-23
 */
@RestController
@RequestMapping("/statistics/template-field")
public class TemplateFieldController extends BaseController {

    @Autowired
    TemplateFieldServiceImpl templateFieldService;

    @PostMapping("/save")
    public CommonResponse save(@RequestBody TemplateField templateField) throws Exception {
        boolean bool = this.templateFieldService.addOrUpdate(templateField);
        return bool ? CommonResponse.success("保存成功") : CommonResponse.error("保存失败");
    }

    @PostMapping("/list")
    public CommonResponse list(@RequestBody TemplateField condition) {
        LambdaQueryWrapper<TemplateField> wrapper = Wrappers.lambdaQuery(condition);
        List<TemplateField> list = this.templateFieldService.list(wrapper);
        return CommonResponse.success(list);
    }

}

